//
//  MVPinTuanGoodsDetailViewController.m
//  LiTianDecoration
//
//  Created by administrator on 2018/7/2.
//  Copyright © 2018年 administrator. All rights reserved.
//

#define kScreenH KScreenHeight - KSafeTopeHeight - KSafeBottomHeight

#import "MVPinTuanGoodsDetailViewController.h"
#import "HSQGoodsDetailHeadBannerCell.h"
#import "HSQGoodsDetailNameViewCell.h"
#import "HSQGoodsDetailFooterView.h"
#import "HSQGoodsDetailFrameModel.h"
#import "HSQCouponRedemptionViewCell.h"
#import "HSQSalesPromotionViewCell.h"
#import "HSQTheSelectedViewCell.h"
#import "HSQAdressListViewCell.h"
#import "HSQTheWeightViewCell.h"
#import "HSQGoodsVolumeViewCell.h"
#import "HSQCommentsCountViewCell.h"
#import "HSQLookUpAllCommentViewCell.h"
#import "HSQConsultingCustomerServiceCell.h"
#import "HSQStoreHeadIntroCell.h"
#import "HSQLookUpGraphicDetailsTableViewCell.h"
#import "HSQVoucherListModel.h"   // 店铺优惠券的模型
#import "HSQGuiGeAndCouperView.h"
#import "HSQContactTheMerchantController.h" // 咨询客服
#import "HSQStoreDetailViewController.h"  // 店铺的详情
#import "HSQGoodsRateListModel.h" // 评论的数据模型
#import "MVGoodsDetailCommentListViewCell.h"
#import "HSQRecommendGoodslListCell.h"  // 为你推荐
#import "HSQGoodsDataListModel.h"  // 商品列表的数据模型
#import "HSQAccountTool.h"
#import "HSQLoginHomeViewController.h"
#import "MVGoodsDetailHomeViewController.h"
#import "HSQPublicAdressView.h"
#import "HSQLoginChooseAdressView.h"
#import "HSQAcceptAddressListModel.h"
#import "HSQGoodsImageDetailViewController.h"
#import "HSQTopNavtionView.h"
#import "HSQGraphicDetailsView.h"
#import "HSQComputerGoodsDetailViewController.h"
#import "HSQLimitedTimeDiscountCell.h"
#import "HSQGoodsDetailPriceCell.h"
#import "HSQGoodsDiscountCell.h"

#import "GKPhoto.h"
#import "GKPhotoBrowser.h"
#import "HSQGoodsRateImageView.h"

@interface MVPinTuanGoodsDetailViewController ()<UITableViewDelegate,UITableViewDataSource,HSQGuiGeAndCouperViewDelegate,HSQStoreHeadIntroCellDelegate,HSQRecommendGoodslListCellDelegate,HSQLoginChooseAdressViewDelegate,HSQGraphicDetailsViewDelegate,HSQGoodsDetailHeadBannerCellDelegate,GKPhotoBrowserDelegate,MVGoodsDetailCommentListViewCellDelegate>

@property (nonatomic, strong) UITableView *tableView;

@property (nonatomic, strong) NSMutableArray *BannerList; // 商品头部图片轮播列表

@property (nonatomic, strong) NSMutableArray *voucherTemplateList; // 店铺优惠券活动

@property (nonatomic, copy) NSString *StoreId; // 店铺的id

@property (nonatomic, strong) NSMutableArray *dataSource; // 用户的收货地址

@property (nonatomic, strong) NSMutableArray *FirstSection_array; // 有多少个cell

@property (nonatomic, strong) NSMutableArray *evaluateGoodsVoList; // 评论的数据

@property (nonatomic, strong) NSMutableArray *SecondSection_array; // 有多少个cell

@property (nonatomic, strong) NSMutableArray *storeCommendList; // 店铺的推荐

@property (nonatomic, strong) NSMutableArray *storeRankingsList; // 店铺的排行

@property (nonatomic, assign) NSInteger Select_Index; // 101代表为你推荐 102 代表排行榜

@property (nonatomic, strong)  HSQGuiGeAndCouperView *GuiGeAndCouperView; // 选择优惠券

@property (nonatomic, copy) NSString *Adress_String; // 选择地区

@property (nonatomic, copy) NSString *allowSend; // 是否有货(1-有货,0-无货)

@property (nonatomic, copy) NSString *goodsStorage; // 商品的库存

@property (nonatomic, copy) NSString *goodsStatus; // 商品的状态 可以购买1，不可购买0

@property (nonatomic, copy) NSString *freightAmount; // 商品的运费

@property (nonatomic, copy) NSString *freightWeight; // 商品的重量

@property (nonatomic, copy) NSString *freightVolume;// 商品体积

@property (nonatomic, copy) NSString *evaluateGoodsTotal;// 商品评论个数

@property (nonatomic, copy) NSString *city_name;// 城市的名字

@property (nonatomic, strong) UIView *Placher_View;

@property (nonatomic, strong) UILabel *Placher_Label;

@property (nonatomic, strong) UIView *Back_View;

@property (nonatomic, strong) HSQGraphicDetailsView *GraphicDetailsView;

@property (nonatomic, strong) NSMutableArray *PhotoBrowser; // 图片浏览器

@property (nonatomic, strong) NSMutableArray *CommentBrowser; // 评论数组

@end

@implementation MVPinTuanGoodsDetailViewController

-(NSMutableArray *)dataSource{
    
    if (_dataSource == nil) {
        
        self.dataSource = [NSMutableArray array];
    }
    
    return _dataSource;
}

- (NSMutableArray *)BannerList{
    
    if (_BannerList == nil) {
        
        self.BannerList = [NSMutableArray array];
    }
    
    return _BannerList;
}

- (NSMutableArray *)FirstSection_array{
    
    if (_FirstSection_array == nil) {
        
        self.FirstSection_array = [NSMutableArray array];
    }
    
    return _FirstSection_array;
}

- (NSMutableArray *)SecondSection_array{
    
    if (_SecondSection_array == nil) {
        
        self.SecondSection_array = [NSMutableArray array];
    }
    
    return _SecondSection_array;
}

- (NSMutableArray *)voucherTemplateList{
    
    if (_voucherTemplateList == nil) {
        
        self.voucherTemplateList = [NSMutableArray array];
    }
    
    return _voucherTemplateList;
}

- (NSMutableArray *)evaluateGoodsVoList{
    
    if (_evaluateGoodsVoList == nil) {
        
        self.evaluateGoodsVoList = [NSMutableArray array];
    }
    
    return _evaluateGoodsVoList;
}

- (NSMutableArray *)storeCommendList{
    
    if (_storeCommendList == nil) {
        
        self.storeCommendList = [NSMutableArray array];
    }
    
    return _storeCommendList;
}

- (NSMutableArray *)storeRankingsList{
    
    if (_storeRankingsList == nil) {
        
        self.storeRankingsList = [NSMutableArray array];
    }
    
    return _storeRankingsList;
}

- (NSMutableArray *)PhotoBrowser{
    
    if (_PhotoBrowser == nil) {
        
        self.PhotoBrowser = [NSMutableArray array];
    }
    
    return _PhotoBrowser;
}

- (NSMutableArray *)CommentBrowser{
    
    if (_CommentBrowser == nil) {
        
        self.CommentBrowser = [NSMutableArray array];
    }
    
    return _CommentBrowser;
}

- (void)viewDidLoad {
    
    [super viewDidLoad];
    
    self.view.backgroundColor = KViewBackGroupColor;
    
    self.Select_Index = 101;
    
    // 底部的视图
    [self AddBottomView];
    
    // 创建tableView
    [self CreatTableView];
    
    // 添加底部提示无货提示
    [self setUpPlacherView];
    
    // 添加底部的刷新效果
    [self AddTableReView];
    
}

/**
 * @brief 底部的视图
 */
- (void)AddBottomView{
    
    UIView *BackView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, kScreenH * 2)];
    
    BackView.backgroundColor = KViewBackGroupColor;
    
    [self.view addSubview:BackView];
    
    self.Back_View = BackView;
    
}

/**
 * @brief 数据赋值
 */
- (void)setResponseObject:(NSDictionary *)responseObject{
    
    _responseObject = responseObject;
    
    self.goodsStorage = [NSString stringWithFormat:@"%@",responseObject[@"datas"][@"groupGoodsDetailVo"][@"goodsList"][0][@"goodsStorage"]];
    
    self.goodsStatus = [NSString stringWithFormat:@"%@",responseObject[@"datas"][@"groupGoodsDetailVo"][@"goodsStatus"]];
    
    if (self.goodsStatus.integerValue != 1)
    {
        self.Placher_View.hidden = NO;
        
        self.Placher_Label.text = @"该商品已下架或售完，可以看看店内其他商品。";
    }
    else
    {
        self.Placher_View.hidden = YES;
        
        self.Placher_Label.text = @"";
    }
    
    // 图片数组
    for (NSDictionary *diction in responseObject[@"datas"][@"groupGoodsDetailVo"][@"goodsImageList"]) {
        
        [self.BannerList addObject:diction[@"imageSrc"]];
    }
    
    [self.BannerList enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        
        GKPhoto *photo = [GKPhoto new];
        
        photo.url = [NSURL URLWithString:obj];
        
        [self.PhotoBrowser addObject:photo];
    }];
    
    // 商品的价格
    NSArray *goodsList = responseObject[@"datas"][@"groupGoodsDetailVo"][@"goodsList"];
    
    NSDictionary *goodsPrice_diction = goodsList.firstObject;
    
    NSString *goodsPrice0 = [NSString stringWithFormat:@"%@",goodsPrice_diction[@"goodsPrice0"]];
    
    self.goodsPrice = [NSString stringWithFormat:@"¥%.2f",goodsPrice0.floatValue];
    
    // 店铺的优惠券
    self.voucherTemplateList = [HSQVoucherListModel mj_objectArrayWithKeyValuesArray:responseObject[@"datas"][@"groupGoodsDetailVo"][@"voucherTemplateList"]];
    
    // 店铺的id
    self.StoreId = [NSString stringWithFormat:@"%@",responseObject[@"datas"][@"storeInfo"][@"storeId"]];
    
    // 已选的规格
    NSArray *GoodsListArray = responseObject[@"datas"][@"groupGoodsDetailVo"][@"goodsList"];
    
    NSDictionary *FirstGoodsDiction = GoodsListArray[0];
    
    self.goodsFullSpecs = [NSString stringWithFormat:@"%@",FirstGoodsDiction[@"goodsSpecString"]];
    
    //  APP端促销是否可用 0不可以 1可用
    NSString *appUsable = [NSString stringWithFormat:@"%@",responseObject[@"datas"][@"appUsable"]];
    
    // 返回几个cell
    [self.FirstSection_array addObject:KBanner]; // 头部的轮播
    
    // 判断是否有显示折扣
    if (![responseObject[@"datas"][@"groupGoodsDetailVo"][@"discount"] isEqual:[NSNull null]])
    {
        [self.FirstSection_array addObject:KShowDiscount]; // 拼团
        
        [self.FirstSection_array addObject:KGoodsName]; // 商品的名字
        
//        [self.FirstSection_array addObject:KLimitedTimeDiscount];
    }
    else
    {
        [self.FirstSection_array addObject:KGoodsName]; // 商品的名字
        
        [self.FirstSection_array addObject:KGoodsPrice]; // 商品的价格
    }
    
    [self.FirstSection_array addObject:KCouponRedemption]; // 领券
    
    // 判断促销是否存在
    if (appUsable.integerValue == 1) {
        
        [self.FirstSection_array addObject:KSalesPromotion]; // 促销
    }
    [self.FirstSection_array addObject:KTheSelected]; // 已选
    
    [self.FirstSection_array addObject:KSentToThe]; // 送至
    
    // 评论的个数
    self.evaluateGoodsTotal = responseObject[@"datas"][@"evaluateGoodsTotal"];
    
    // 评论的数组
    self.evaluateGoodsVoList = [HSQGoodsRateListModel mj_objectArrayWithKeyValuesArray:responseObject[@"datas"][@"evaluateGoodsVoList"]];
    
    if (self.evaluateGoodsTotal.integerValue != 0)
    {
        [self.FirstSection_array addObject:KNumberOfComments]; // 评论的数量
        
        [self.SecondSection_array addObject:KLookUpAllRate]; // 全部评论
    }
    
    [self.SecondSection_array addObject:KConsultingService]; // 咨询客服
    
    [self.SecondSection_array addObject:KStoreIntroduce];  // 店铺的介绍
    
    // 判断为你推荐或者排行旁是否存在
    self.storeCommendList = [HSQGoodsDataListModel mj_objectArrayWithKeyValuesArray:responseObject[@"datas"][@"storeCommendList"]];
    
    self.storeRankingsList = [HSQGoodsDataListModel mj_objectArrayWithKeyValuesArray:responseObject[@"datas"][@"storeRankingsList"]];
    
    if (self.storeCommendList.count != 0 && self.storeRankingsList.count != 0) {
        
        [self.SecondSection_array addObject:KStoreCommendList];  // 为你推荐
    }
    
    // 滑动查看详情
    [self.SecondSection_array addObject:KYouSlide];
    
    // 请求用户的地址
    [self RequestStoreCouponData];
    
    // 图文详情
    HSQGraphicDetailsView *GraphicDetailsView = [[HSQGraphicDetailsView alloc] initWithFrame:CGRectMake(0, kScreenH, KScreenWidth, kScreenH)];
    
    GraphicDetailsView.commonId = responseObject[@"datas"][@"groupGoodsDetailVo"][@"commonId"];
    
    GraphicDetailsView.delegate = self;
    
    [self.Back_View addSubview:GraphicDetailsView];
    
    self.GraphicDetailsView = GraphicDetailsView;
    
    [self.tableView reloadData];
}

/**
 * @brief 商品详细信息 配送及运费信息(和拼团共用)
 * @params areaId2 市级地址
 */
- (void)ShippingAndShippingDetailsSharedWithTheGroupWithcommonId:(NSString *)commonId buyNum:(NSString *)buyNum areaId2:(NSString *)areaId2{
    
    NSDictionary *params = @{@"commonId":commonId,@"buyNum":buyNum,@"areaId2":areaId2};
    
    AFNetworkRequestTool *RequestTool = [AFNetworkRequestTool shareRequestTool];
    
    [RequestTool.manger POST:UrlAdress(KGoodsDetailSendInfo) parameters:params progress:^(NSProgress * _Nonnull downloadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        [[HSQProgressHUDManger Manger] DismissProgressHUD];
        
        HSQLog(@"===商品详细信息 配送及运费信===%@",responseObject);
        
        HSQLog(@"=goodsState=====%@===%@",self.goodsStorage,self.allowSend);
        
        if ([responseObject[@"code"] integerValue] == 200)
        {
            self.allowSend = [NSString stringWithFormat:@"%@",responseObject[@"datas"][@"allowSend"]];
            
            // 首先判断该地区是否有货或者库存是否为0
            if (self.goodsStorage.integerValue < 1 || self.allowSend.integerValue != 1)
            {
                self.Placher_View.hidden = NO;
                
                self.Placher_Label.text = @"所选地区暂时无货，非常抱歉！";
            }
            else
            {
                self.Placher_View.hidden = YES;
                
                self.Placher_Label.text = @"";
            }
            
            // 商品的运费
            self.freightAmount = [NSString stringWithFormat:@"%@",responseObject[@"datas"][@"freightAmount"]];
            
            // 商品的重量
            self.freightWeight = [NSString stringWithFormat:@"%@",responseObject[@"datas"][@"freightWeight"]];
            
            // 商品体积
            self.freightVolume = [NSString stringWithFormat:@"%@",responseObject[@"datas"][@"freightVolume"]];
            
            if (self.allowSend.integerValue != 0) // 有货
            {
                [self.FirstSection_array removeObject:KfreightWeight];
                
                [self.FirstSection_array removeObject:KfreightVolume];
                
                if (self.evaluateGoodsTotal.integerValue != 0)
                {
                    [self.FirstSection_array insertObject:KfreightWeight atIndex:self.FirstSection_array.count - 1];
                    
                    [self.FirstSection_array insertObject:KfreightVolume atIndex:self.FirstSection_array.count - 2];
                }
                else
                {
                    [self.FirstSection_array insertObject:KfreightWeight atIndex:self.FirstSection_array.count];
                    
                    [self.FirstSection_array insertObject:KfreightVolume atIndex:self.FirstSection_array.count];
                }
            }
        }
        else
        {
            self.Adress_String = [NSString stringWithFormat:@"%@",responseObject[@"datas"][@"error"]];
            
            self.allowSend = @"100";
        }
        
        [self.tableView reloadData];
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
        self.allowSend = @"100";
        
        [self.tableView reloadData];
        
        [[HSQProgressHUDManger Manger] ShowDisplayFailedToLoadData:KErrorPlacherString SuperView:self.view];
        
    }];
}

/**
 * @brief 商品的规格
 */
- (void)setGoodsFullSpecs:(NSString *)goodsFullSpecs{
    
    _goodsFullSpecs = goodsFullSpecs;
    
    [self.tableView reloadData];
}

/**
 * @brief 商品的价格
 */
- (void)setGoodsPrice:(NSString *)goodsPrice{
    
    _goodsPrice = goodsPrice;
    
    [self.tableView reloadData];
}

/**
 * @brief 商品的价格
 */
- (void)setAdress_String:(NSString *)Adress_String{
    
    _Adress_String = Adress_String;
    
    [self.tableView reloadData];
}

/**
 * @brief 创建tableView
 */
- (void)CreatTableView{
    
    UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight - KSafeTopeHeight - KSafeBottomHeight - 50) style:(UITableViewStylePlain)];
    
    tableView.backgroundColor = [UIColor clearColor];
    
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    tableView.dataSource = self;
    
    tableView.delegate = self;
    
    tableView.showsVerticalScrollIndicator = NO;
    
    tableView.showsHorizontalScrollIndicator = NO;
    
    tableView.contentSize = CGSizeMake(KScreenWidth, kScreenH * 2);
    
    // 轮播图
    [tableView registerClass:[HSQGoodsDetailHeadBannerCell class] forCellReuseIdentifier:@"HSQGoodsDetailHeadBannerCell"];
    
    // 限时折扣的提示cell
    [tableView registerClass:[HSQGoodsDiscountCell class] forCellReuseIdentifier:@"HSQGoodsDiscountCell"];
    
    // 商品的名字
    [tableView registerClass:[HSQGoodsDetailNameViewCell class] forCellReuseIdentifier:@"HSQGoodsDetailNameViewCell"];
    
    // 商品的价格
    [tableView registerClass:[HSQGoodsDetailPriceCell class] forCellReuseIdentifier:@"HSQGoodsDetailPriceCell"];
    
    // 限时折扣
    [tableView registerNib:[UINib nibWithNibName:@"HSQLimitedTimeDiscountCell" bundle:nil] forCellReuseIdentifier:@"HSQLimitedTimeDiscountCell"];
    
    // 领券
    [tableView registerClass:[HSQCouponRedemptionViewCell class] forCellReuseIdentifier:@"HSQCouponRedemptionViewCell"];
    
    // 促销
    [tableView registerNib:[UINib nibWithNibName:@"HSQSalesPromotionViewCell" bundle:nil] forCellReuseIdentifier:@"HSQSalesPromotionViewCell"];
    
    // 已选
    [tableView registerNib:[UINib nibWithNibName:@"HSQTheSelectedViewCell" bundle:nil] forCellReuseIdentifier:@"HSQTheSelectedViewCell"];
    
    // 送至
    [tableView registerNib:[UINib nibWithNibName:@"HSQAdressListViewCell" bundle:nil] forCellReuseIdentifier:@"HSQAdressListViewCell"];
    
    // 体重
    [tableView registerClass:[HSQTheWeightViewCell class] forCellReuseIdentifier:@"HSQTheWeightViewCell"];
    
    // 体积
    [tableView registerClass:[HSQGoodsVolumeViewCell class] forCellReuseIdentifier:@"HSQGoodsVolumeViewCell"];
    
    // 评论
    [tableView registerClass:[HSQCommentsCountViewCell class] forCellReuseIdentifier:@"HSQCommentsCountViewCell"];
    
    // 查看全部评论
    [tableView registerClass:[HSQLookUpAllCommentViewCell class] forCellReuseIdentifier:@"HSQLookUpAllCommentViewCell"];
    
    // 咨询店铺的提示
    [tableView registerNib:[UINib nibWithNibName:@"HSQConsultingCustomerServiceCell" bundle:nil] forCellReuseIdentifier:@"HSQConsultingCustomerServiceCell"];
    
    // 商品的评论
    [tableView registerClass:[MVGoodsDetailCommentListViewCell class] forCellReuseIdentifier:@"MVGoodsDetailCommentListViewCell"];
    
    // 店铺的介绍
    [tableView registerNib:[UINib nibWithNibName:@"HSQStoreHeadIntroCell" bundle:nil] forCellReuseIdentifier:@"HSQStoreHeadIntroCell"];
    
    // 为你推荐
    [tableView registerClass:[HSQRecommendGoodslListCell class] forCellReuseIdentifier:@"HSQRecommendGoodslListCell"];
    
    // 上拉查看图文详情
    [tableView registerClass:[HSQLookUpGraphicDetailsTableViewCell class] forCellReuseIdentifier:@"HSQLookUpGraphicDetailsTableViewCell"];
    
    [self.Back_View addSubview:tableView];
    
    self.tableView = tableView;
    
}

/**
 * @brief 添加底部上拉查看图文详情
 */
- (void)AddTableReView{
    
    MJRefreshBackNormalFooter *footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(shanglaClickAction)];
    
    footer.arrowView.image = [UIImage ImageWithColor:KViewBackGroupColor];
    
    footer.stateLabel.hidden = YES;
    
    self.tableView.mj_footer = footer;
    
}

- (void)shanglaClickAction{
    
    [UIView animateWithDuration:0.25 animations:^{
        
        if (self.delegate && [self.delegate respondsToSelector:@selector(ScrollupToSeeGraphicDetails:)]) {
            
            [self.delegate ScrollupToSeeGraphicDetails:100];
        }
        
        //下拉执行对应的操作
        self.tableView.mj_y = -kScreenH;
        
        self.GraphicDetailsView.mj_y = 0;
        
        [self.tableView.mj_footer endRefreshing];
    }];
}

/**
 * @brief 下拉查看商品的详情
 */
- (void)TheDropDownShowsTheProductDetails{
    
    [UIView animateWithDuration:0.25 animations:^{
        
        if (self.delegate && [self.delegate respondsToSelector:@selector(ScrollupToSeeGraphicDetails:)]) {
            
            [self.delegate ScrollupToSeeGraphicDetails:200];
        }
        
        //下拉执行对应的操作
        self.tableView.mj_y = 0;
        
        self.GraphicDetailsView.mj_y = kScreenH;
        
    }];
}

/**
 * @brief 进入电脑版详情
 */
- (void)JoinComputerGoodsDetail:(UIButton *)sender{
    
    HSQComputerGoodsDetailViewController *computerVC = [[HSQComputerGoodsDetailViewController alloc] init];
    
    computerVC.commonId = self.responseObject[@"datas"][@"goodsDetail"][@"commonId"];
    
    [self.navigationController pushViewController:computerVC animated:YES];
}

/**
 * @brief 创建底部提示视图
 */
- (void)setUpPlacherView{
    
    UIView *placher_View = [[UIView alloc] initWithFrame:CGRectMake(0, KScreenHeight - KSafeTopeHeight - KSafeBottomHeight - 50 - 30, KScreenWidth, 30)];
    
    placher_View.backgroundColor = [RGB(247, 211, 97) colorWithAlphaComponent:0.8];
    
    placher_View.hidden = YES;
    
    [self.view addSubview:placher_View];
    
    self.Placher_View = placher_View;
    
    UILabel *placher_Label = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, KScreenWidth - 20, 30)];
    
    placher_Label.font = [UIFont systemFontOfSize:KLabelFont(14.0, 12.0)];
    
    placher_Label.textAlignment = NSTextAlignmentCenter;
    
    [placher_View addSubview:placher_Label];
    
    self.Placher_Label = placher_Label;
    
}

- (void)didReceiveMemoryWarning {
    
    [super didReceiveMemoryWarning];
    
}

#pragma mark - UITableViewDelegate,UITableViewDataSource

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 3;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    if (section == 0)
    {
        return self.FirstSection_array.count;
    }
    else  if (section == 1)
    {
        return self.evaluateGoodsVoList.count;
    }
    else
    {
        return self.SecondSection_array.count;
    }
}

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.section == 0)
    {
        NSString *type = self.FirstSection_array[indexPath.row];
        
        if ([type isEqualToString:KBanner]) // 头部轮播
        {
            return KScreenWidth;
        }
        else if ([type isEqualToString:KShowDiscount]) // 商品的限时折扣
        {
            return 60;
        }
        else if ([type isEqualToString:KGoodsName]) // 商品的名字
        {
            NSString *goodsName = self.responseObject[@"datas"][@"goodsDetail"][@"goodsName"];
            
            NSString *isOwnShop = [NSString stringWithFormat:@"%@",self.responseObject[@"datas"][@"storeInfo"][@"isOwnShop"]];
            
            return [[HSQGoodsDetailFrameModel shareGoodsDetailFrameModel] HeightWithGoodsName:goodsName GoodsDescribe:self.responseObject[@"datas"][@"goodsDetail"][@"jingle"] isOwnShop:isOwnShop];
            
        }
        else if ([type isEqualToString:KGoodsPrice]) // 商品的价格
        {
            return 25;
        }
        else if ([type isEqualToString:KLimitedTimeDiscount]) // 限时折扣
        {
            return 90;
        }
        else if ([type isEqualToString:KCouponRedemption]) // 领券
        {
            return 50;
        }
        else if ([type isEqualToString:KSalesPromotion]) // 促销
        {
            return 50;
        }
        else if ([type isEqualToString:KTheSelected]) // 已选
        {
            return 50;
        }
        else if ([type isEqualToString:KSentToThe]) // 送至
        {
            return 50;
        }
        else if ([type isEqualToString:KfreightWeight]) // 体重
        {
            return 30;
        }
        else if ([type isEqualToString:KfreightVolume]) // 体积
        {
            return 30;
        }
        else if ([type isEqualToString:KNumberOfComments]) // 评论
        {
            return 50;
        }
        else
        {
            return 0;
        }
    }
    else if (indexPath.section == 1)
    {
        HSQGoodsRateListModel *model = self.evaluateGoodsVoList[indexPath.row];
        
        return model.CellHeight;
    }
    else
    {
        NSString *type = self.SecondSection_array[indexPath.row];
        
        if ([type isEqualToString:KConsultingService]) // 咨询
        {
            return 50;
        }
        else if ([type isEqualToString:KLookUpAllRate]) // 全部评论
        {
            return 50;
        }
        else if ([type isEqualToString:KStoreIntroduce]) // 店铺的介绍
        {
            return 200;
        }
        else if ([type isEqualToString:KStoreCommendList]) // 为你推荐
        {
            if (self.Select_Index == 101) // 为你推KRecommendNumber荐
            {
                return 60 + (self.storeCommendList.count > 3 ? KScreenWidth : KScreenWidth / 2);
            }
            else // 排行榜
            {
                return 60 + (self.storeRankingsList.count > 3 ? KScreenWidth : KScreenWidth / 2);
            }
        }
        else if ([type isEqualToString:KYouSlide]) // 滑动查看详情
        {
            return 50;
        }
        else
        {
            return 100;
        }
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.section == 0)
    {
        NSString *type = self.FirstSection_array[indexPath.row];
        
        if ([type isEqualToString:KBanner]) // 头部轮播
        {
            return KScreenWidth;
        }
        else if ([type isEqualToString:KShowDiscount]) // 商品的限时折扣
        {
            return 60;
        }
        else if ([type isEqualToString:KGoodsName]) // 商品的名字
        {
            NSString *goodsName = self.responseObject[@"datas"][@"groupGoodsDetailVo"][@"goodsName"];
            
            NSString *isOwnShop = [NSString stringWithFormat:@"%@",self.responseObject[@"datas"][@"storeInfo"][@"isOwnShop"]];
            
            return [[HSQGoodsDetailFrameModel shareGoodsDetailFrameModel] HeightWithGoodsName:goodsName GoodsDescribe:self.responseObject[@"datas"][@"groupGoodsDetailVo"][@"jingle"] isOwnShop:isOwnShop];
        }
        else if ([type isEqualToString:KGoodsPrice]) // 商品的价格
        {
            return 25;
        }
        else if ([type isEqualToString:KLimitedTimeDiscount]) // 限时折扣
        {
            return 90;
        }
        else if ([type isEqualToString:KCouponRedemption]) // 领券
        {
            return 50;
        }
        else if ([type isEqualToString:KSalesPromotion]) // 促销
        {
            return 50;
        }
        else if ([type isEqualToString:KTheSelected]) // 已选
        {
            return 50;
        }
        else if ([type isEqualToString:KSentToThe]) // 送至KNumberOfComments
        {
            return 50;
        }
        else if ([type isEqualToString:KfreightWeight]) // 体重
        {
            return 30;
        }
        else if ([type isEqualToString:KfreightVolume]) // 体积
        {
            return 30;
        }
        else if ([type isEqualToString:KNumberOfComments]) // 评论
        {
            return 50;
        }
        else
        {
            return 0;
        }
    }
    else if (indexPath.section == 1)
    {
        HSQGoodsRateListModel *model = self.evaluateGoodsVoList[indexPath.row];
        
        return model.CellHeight;
    }
    else
    {
        NSString *type = self.SecondSection_array[indexPath.row];
        
        if ([type isEqualToString:KConsultingService]) // 咨询
        {
            return 50;
        }
        else if ([type isEqualToString:KLookUpAllRate]) // 全部评论
        {
            return 50;
        }
        else if ([type isEqualToString:KStoreIntroduce]) // 店铺的介绍
        {
            return 200;
        }
        else if ([type isEqualToString:KStoreCommendList]) // 为你推荐
        {
            if (self.Select_Index == 101) // 为你推KRecommendNumber荐
            {
                return 60 + (self.storeCommendList.count > 3 ? KScreenWidth : KScreenWidth / 2);
            }
            else // 排行榜
            {
                return 60 + (self.storeRankingsList.count > 3 ? KScreenWidth : KScreenWidth / 2);
            }
        }
        else if ([type isEqualToString:KYouSlide]) // 滑动查看详情
        {
            return 50;
        }
        else
        {
            return 100;
        }
    }
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.section == 0)
    {
        NSString *type = self.FirstSection_array[indexPath.row];
        
        if ([type isEqualToString:KBanner]) // 头部轮播
        {
            HSQGoodsDetailHeadBannerCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HSQGoodsDetailHeadBannerCell" forIndexPath:indexPath];
            
            cell.Banners = self.BannerList;
            
            cell.delegate = self;
            
            return cell;
        }
        else if ([type isEqualToString:KShowDiscount]) // 商品的拼团数据
        {
            HSQGoodsDiscountCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HSQGoodsDiscountCell" forIndexPath:indexPath];
            
            cell.PinTuan_diction = self.responseObject[@"datas"];
            
            return cell;
        }
        else if ([type isEqualToString:KGoodsName]) // 商品的名字
        {
            HSQGoodsDetailNameViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HSQGoodsDetailNameViewCell" forIndexPath:indexPath];
            
            cell.PinTuan_Goods_Diction = self.responseObject[@"datas"];
            
            return cell;
        }
        else if ([type isEqualToString:KGoodsPrice]) // 商品的价格
        {
            HSQGoodsDetailPriceCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HSQGoodsDetailPriceCell" forIndexPath:indexPath];
            
            cell.appPrice0_Label.text = [NSString stringWithFormat:@"%@",self.goodsPrice];
            
            return cell;
        }
        else if ([type isEqualToString:KLimitedTimeDiscount]) // 限时折扣
        {
            HSQLimitedTimeDiscountCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HSQLimitedTimeDiscountCell" forIndexPath:indexPath];
            
            // 折扣的价格
            NSString *appPrice0 = [NSString stringWithFormat:@"价格  ¥%.2f",[self.responseObject[@"datas"][@"goodsDetail"][@"appPrice0"] floatValue]];
            NSMutableAttributedString *appPrice0_attribe = [[NSMutableAttributedString alloc] initWithString:appPrice0];
            [appPrice0_attribe addAttribute:NSForegroundColorAttributeName value:RGB(150, 150, 150) range:NSMakeRange(0, 2)];
            [appPrice0_attribe addAttribute:NSForegroundColorAttributeName value:RGB(238, 58, 68) range:NSMakeRange(2, appPrice0.length - 2)];
            [appPrice0_attribe addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14.0] range:NSMakeRange(2, appPrice0.length - 2)];
            cell.appPrice0_Label.attributedText = appPrice0_attribe;
            
            // 折扣的描述
            NSString *discountExplain = [NSString stringWithFormat:@"描述  %@",self.responseObject[@"datas"][@"goodsDetail"][@"discount"][@"discountExplain"]];
            NSMutableAttributedString *discountExplain_attribe = [[NSMutableAttributedString alloc] initWithString:discountExplain];
            [discountExplain_attribe addAttribute:NSForegroundColorAttributeName value:RGB(150, 150, 150) range:NSMakeRange(0, 2)];
            cell.discountExplain_Label.attributedText = discountExplain_attribe;
            
            // 折扣的描述
            NSString *discount_time = [NSString stringWithFormat:@"时间  %@至%@",self.responseObject[@"datas"][@"goodsDetail"][@"discount"][@"startTime"],self.responseObject[@"datas"][@"goodsDetail"][@"discount"][@"endTime"]];
            NSMutableAttributedString *discount_time_attribe = [[NSMutableAttributedString alloc] initWithString:discount_time];
            [discount_time_attribe addAttribute:NSForegroundColorAttributeName value:RGB(150, 150, 150) range:NSMakeRange(0, 2)];
            cell.discount_Label.attributedText = discount_time_attribe;
            
            return cell;
        }
        else if ([type isEqualToString:KCouponRedemption]) // 领券
        {
            HSQCouponRedemptionViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HSQCouponRedemptionViewCell" forIndexPath:indexPath];
            
            cell.voucherTemplateList = self.voucherTemplateList;
            
            return cell;
        }
        else if ([type isEqualToString:KSalesPromotion]) // 促销
        {
            HSQSalesPromotionViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HSQSalesPromotionViewCell" forIndexPath:indexPath];
            
            return cell;
        }
        else if ([type isEqualToString:KTheSelected]) // 已选
        {
            HSQTheSelectedViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HSQTheSelectedViewCell" forIndexPath:indexPath];
            
            cell.goodsFullSpecs = self.goodsFullSpecs;
            
            return cell;
        }
        else if ([type isEqualToString:KSentToThe]) // 送至
        {
            HSQAdressListViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HSQAdressListViewCell" forIndexPath:indexPath];
            
            if (self.allowSend.integerValue == 100) // 说明请求商品有误货数据失败
            {
                cell.placher_Label.text = self.Adress_String;
                
                cell.Adress_Label.hidden = YES;
                
                cell.Goods_label.hidden = YES;
                
                cell.placher_Label.hidden = NO;
                
                cell.Adress_Label.text = cell.Goods_label.text = @"";
            }
            else if (self.allowSend.integerValue == 0) // 无货
            {
                cell.placher_Label.hidden = YES;
                cell.placher_Label.text = @"";
                
                cell.Adress_Label.hidden = cell.Goods_label.hidden = NO;
                
                cell.Adress_Label.text = self.Adress_String;
                
                NSMutableAttributedString *attribeString = [[NSMutableAttributedString alloc] initWithString:@"无货"];
                [attribeString addAttribute:NSForegroundColorAttributeName value:RGB(238, 58, 68) range:NSMakeRange(0, 2)];
                cell.Goods_label.attributedText = attribeString;
                
            }
            else if (self.allowSend.integerValue == 1) // 有货
            {
                if (self.freightAmount.integerValue == 0) // 免运费
                {
                    cell.placher_Label.hidden = YES;
                    cell.placher_Label.text = @"";
                    
                    cell.Adress_Label.hidden = cell.Goods_label.hidden = NO;
                    
                    cell.Adress_Label.text = self.Adress_String;
                    
                    NSMutableAttributedString *attribeString = [[NSMutableAttributedString alloc] initWithString:@"现货 免运费 "];
                    [attribeString addAttribute:NSForegroundColorAttributeName value:RGB(238, 58, 68) range:NSMakeRange(0, 2)];
                    cell.Goods_label.attributedText = attribeString;
                }
                else
                {
                    NSString *string = [NSString stringWithFormat:@"现货 运费%@元",self.freightAmount];
                    
                    cell.placher_Label.hidden = YES;
                    cell.placher_Label.text = @"";
                    
                    cell.Adress_Label.hidden = cell.Goods_label.hidden = NO;
                    
                    cell.Adress_Label.text = self.Adress_String;
                    
                    NSMutableAttributedString *attribeString = [[NSMutableAttributedString alloc] initWithString:string];
                    [attribeString addAttribute:NSForegroundColorAttributeName value:RGB(238, 58, 68) range:NSMakeRange(0, 2)];
                    cell.Goods_label.attributedText = attribeString;
                }
            }
            else
            {
                cell.placher_Label.text = self.Adress_String;
                
                cell.Goods_label.hidden = cell.Adress_Label.hidden = YES;
            }
            
            return cell;
        }
        else if ([type isEqualToString:KfreightWeight]) // 体重
        {
            HSQTheWeightViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HSQTheWeightViewCell" forIndexPath:indexPath];
            
            cell.freightWeight_Label.text = [NSString stringWithFormat:@"%@kg",self.freightWeight];
            
            return cell;
        }
        else if ([type isEqualToString:KfreightVolume]) // 体积
        {
            HSQGoodsVolumeViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HSQGoodsVolumeViewCell" forIndexPath:indexPath];
            
            cell.freightVolume_Label.text = [NSString stringWithFormat:@"%@m³",self.freightVolume];
            
            return cell;
        }
        else if ([type isEqualToString:KNumberOfComments]) // 评论数量
        {
            HSQCommentsCountViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HSQCommentsCountViewCell" forIndexPath:indexPath];
            
            cell.datas = self.responseObject[@"datas"];
            
            return cell;
        }
        else
        {
            return nil;
        }
    }
    else if (indexPath.section == 1) // 评论
    {
        MVGoodsDetailCommentListViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MVGoodsDetailCommentListViewCell" forIndexPath:indexPath];
        
        cell.model = self.evaluateGoodsVoList[indexPath.row];
        
        cell.delegate = self;
        
        return cell;
    }
    else
    {
        NSString *type = self.SecondSection_array[indexPath.row];
        
        if ([type isEqualToString:KLookUpAllRate]) // 全部评论
        {
            HSQLookUpAllCommentViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HSQLookUpAllCommentViewCell" forIndexPath:indexPath];
            
            cell.datas = self.responseObject[@"datas"];
            
            return cell;
        }
        else if ([type isEqualToString:KConsultingService]) // 咨询客服
        {
            HSQConsultingCustomerServiceCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HSQConsultingCustomerServiceCell" forIndexPath:indexPath];
            
            return cell;
        }
        else if ([type isEqualToString:KStoreIntroduce]) // 店铺的介绍
        {
            HSQStoreHeadIntroCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HSQStoreHeadIntroCell" forIndexPath:indexPath];
            
            cell.DataDiction = self.responseObject[@"datas"];
            
            cell.delegate = self;
            
            return cell;
        }
        else if ([type isEqualToString:KStoreCommendList]) // 为你推荐
        {
            HSQRecommendGoodslListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HSQRecommendGoodslListCell" forIndexPath:indexPath];
            
            cell.delegate = self;
            
            if (self.Select_Index == 101) // 为你推荐
            {
                cell.DataSource = self.storeCommendList;
            }
            else // 排行榜
            {
                cell.DataSource = self.storeRankingsList;
            }
            
            cell.Select_Index = self.Select_Index;
            
            return cell;
        }
        else if ([type isEqualToString:KYouSlide]) // 滑动查看详情
        {
            HSQLookUpGraphicDetailsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HSQLookUpGraphicDetailsTableViewCell" forIndexPath:indexPath];
            
            return cell;
        }
        else
        {
            return nil;
        }
    }
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
//    if (self.goodsStatus.integerValue == 0) return;
    
    if (indexPath.section == 0)
    {
        NSString *type = self.FirstSection_array[indexPath.row];
        
        if ([type isEqualToString:KCouponRedemption]) // 领券
        {
            [self ShowTheCouponListClickAction];
        }
        else if ([type isEqualToString:KSalesPromotion]) // 促销
        {
            
        }
        else if ([type isEqualToString:KTheSelected]) // 已选
        {
            if (self.delegate && [self.delegate respondsToSelector:@selector(ChooseTheSpecificationsOfTheGoods:)]) {
                
                [self.delegate ChooseTheSpecificationsOfTheGoods:indexPath];
            }
        }
        else if ([type isEqualToString:KSentToThe]) // 送至
        {
            // 选择收货地址
            [self SelecttheShippingAddress];
            
        }
        else if ([type isEqualToString:KNumberOfComments]) // 评论
        {
            if (self.delegate && [self.delegate respondsToSelector:@selector(LookUpAllGoodsComment)]) {
                
                [self.delegate LookUpAllGoodsComment];
            }
        }
    }
    else if (indexPath.section == 1) // 评论列表
    {
        
    }
    else if (indexPath.section == 2)
    {
        NSString *type = self.SecondSection_array[indexPath.row];
        
        if ([type isEqualToString:KConsultingService]) // 咨询客服
        {
            HSQContactTheMerchantController *ContactTheMerchantVC = [[HSQContactTheMerchantController alloc] init];
            
            ContactTheMerchantVC.sid = [NSString stringWithFormat:@"%@",self.responseObject[@"datas"][@"storeInfo"][@"sellerId"]];
            
            [self.navigationController pushViewController:ContactTheMerchantVC animated:YES];
        }
        else if ([type isEqualToString:KLookUpAllRate]) // 全部评论
        {
            if (self.delegate && [self.delegate respondsToSelector:@selector(LookUpAllGoodsComment)]) {
                
                [self.delegate LookUpAllGoodsComment];
            }
        }
    }
}

/**
 * @brief 显示领券列表
 */
- (void)ShowTheCouponListClickAction{
    
    HSQGuiGeAndCouperView *GuiGeAndCouperView = [HSQGuiGeAndCouperView initGuiGeAndCouperView];
    
    GuiGeAndCouperView.placherString = @"适用优惠券";
    
    GuiGeAndCouperView.delegate = self;
    
    GuiGeAndCouperView.TypeString = @"100";
    
    GuiGeAndCouperView.storeId = self.StoreId;
    
    [GuiGeAndCouperView ShowGuiGeAndCouperView];
    
    self.GuiGeAndCouperView = GuiGeAndCouperView;
}

/**
 * @brief 领取优惠券
 */
- (void)ChooseGuiGeAndCoupter:(NSIndexPath *)indexPath templateId:(NSString *)templateId{
    
    [self.GuiGeAndCouperView dismissAdressView];
    
    HSQLoginHomeViewController *LoginVC = [[HSQLoginHomeViewController alloc] init];
    
    [self.navigationController pushViewController:LoginVC animated:YES];
}

/**
 * @brief 联系商家
 */
- (void)ContactTheMerchantButtonClickAction:(UIButton *)sender{
    
    HSQContactTheMerchantController *ContactTheMerchantVC = [[HSQContactTheMerchantController alloc] init];
    
    ContactTheMerchantVC.sid = [NSString stringWithFormat:@"%@",self.responseObject[@"datas"][@"storeInfo"][@"sellerId"]];
    
    [self.navigationController pushViewController:ContactTheMerchantVC animated:YES];
}

/**
 * @brief 进入店铺
 */
- (void)EnterTheStoreButtonClickAction:(UIButton *)sender{
    
    HSQStoreDetailViewController *storeDetailVC = [[HSQStoreDetailViewController alloc] init];
    
    storeDetailVC.storeId = self.responseObject[@"datas"][@"storeInfo"][@"storeId"];
    
    [self.navigationController pushViewController:storeDetailVC animated:YES];
    
}

/**
 * @brief 为你推荐商品的点击
 */
- (void)RecommendGoodslListButtonClickAction:(UIButton *)sender goodID:(NSString *)commonId{
    
    MVGoodsDetailHomeViewController *GoodsDetailHomeVC = [[MVGoodsDetailHomeViewController alloc] init];
    
    GoodsDetailHomeVC.commond_id = commonId;
    
    [self.navigationController pushViewController:GoodsDetailHomeVC animated:YES];
}

/**
 * @brief 为你推荐或者排行榜按钮的点击
 */
- (void)RecommendOrRankButtonClickForYou:(UIButton *)sender{
    
    self.Select_Index = sender.tag;
    
    [self.tableView reloadData];
    
}

/**
 * @brief 请求会员的收货地址
 */
- (void)RequestStoreCouponData{
    
    // 判断用户有没有登录
    NSString *token = [HSQAccountTool account].token;
    
    if (token.length == 0)
    {
        // 判断商品是否有货
        [self ShippingAndShippingDetailsSharedWithTheGroupWithcommonId:self.responseObject[@"datas"][@"groupGoodsDetailVo"][@"commonId"] buyNum:@"1" areaId2:@"0"];
    }
    else
    {
        [[HSQProgressHUDManger Manger] ShowLoadingDataFromeServer:@"" ToView:self.view IsClearColor:YES];
        
        [self.dataSource removeAllObjects];
        
        NSDictionary *diction = @{@"token":[HSQAccountTool account].token};
        
        AFNetworkRequestTool *RequestTool = [AFNetworkRequestTool shareRequestTool];
        
        [RequestTool.manger POST:UrlAdress(KadressListUrl) parameters:diction progress:^(NSProgress * _Nonnull uploadProgress) {
            
        } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
            
            HSQLog(@"==shouhuodizhi=%@",responseObject);
            
            [[HSQProgressHUDManger Manger] DismissProgressHUD];
            
            if ([responseObject[@"code"] integerValue] == 200)
            {
                self.dataSource = [HSQAcceptAddressListModel mj_objectArrayWithKeyValuesArray:responseObject[@"datas"][@"addressList"]];
                
                if (self.dataSource.count != 0)
                {
                    HSQAcceptAddressListModel *adressModel = self.dataSource.firstObject;
                    
                    self.Adress_String = adressModel.adressName;
                    
                    self.city_name = adressModel.adressName;
                    
                    // 判断商品是否有货
                    [self ShippingAndShippingDetailsSharedWithTheGroupWithcommonId:self.responseObject[@"datas"][@"groupGoodsDetailVo"][@"commonId"] buyNum:@"1" areaId2:adressModel.areaId2];
                }
                else
                {
                    // 判断商品是否有货
                    [self ShippingAndShippingDetailsSharedWithTheGroupWithcommonId:self.responseObject[@"datas"][@"groupGoodsDetailVo"][@"commonId"] buyNum:@"1" areaId2:@"0"];
                }
            }
            else
            {
                NSString *errorString = [NSString stringWithFormat:@"%@",responseObject[@"datas"][@"error"]];
                
                [[HSQProgressHUDManger Manger] ShowDisplayFailedToLoadData:errorString SuperView:self.view];
            }
            
            [self.tableView reloadData];
            
        } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
            
            [[HSQProgressHUDManger Manger] ShowDisplayFailedToLoadData:KErrorPlacherString SuperView:self.view];
        }];
    }
}

/**
 * @brief 选择收货地址
 */
- (void)SelecttheShippingAddress{
    
    // 1.判断用户是否登录
    NSString *token = [HSQAccountTool account].token;
    
    if (token.length == 0) // 没有登录
    {
        HSQPublicAdressView *adressView = [HSQPublicAdressView initAdressView];
        
        adressView.placherString = @"配送至";
        
        [adressView ShowAdressView];
        
        adressView.chooseFinish = ^(NSString *adress,NSString *ProvinceId, NSString *cityId, NSString *AreaId){
            
            HSQLog(@"===%@==%@===%@==%@",adress,ProvinceId,cityId,AreaId);
            
            self.Adress_String = adress;
            
            self.city_name = @"";
            
            // 判断商品是否有货
            [self ShippingAndShippingDetailsSharedWithTheGroupWithcommonId:self.responseObject[@"datas"][@"groupGoodsDetailVo"][@"commonId"] buyNum:@"1" areaId2:cityId];
        };
    }
    else
    {
        
        HSQLoginChooseAdressView *GuiGeAndCouperView = [HSQLoginChooseAdressView initGuiGeAndCouperView];
        
        GuiGeAndCouperView.placherString = @"配送至";
        
        GuiGeAndCouperView.delegate = self;
        
        GuiGeAndCouperView.dataSource = self.dataSource;
        
        GuiGeAndCouperView.city_name = self.city_name;
        
        [GuiGeAndCouperView ShowLoginChooseAdressView];
        
    }
}

/**
 * @brief 选择收货地址
 */
- (void)ChooseMemberAdressWithModel:(NSString *)AdressName Adreid:(NSString *)adreid2{
    
    self.Adress_String = AdressName;
    
    self.city_name = AdressName;
    
    // 判断商品是否有货
    [self ShippingAndShippingDetailsSharedWithTheGroupWithcommonId:self.responseObject[@"datas"][@"groupGoodsDetailVo"][@"commonId"] buyNum:@"1" areaId2:adreid2];
}

/**
 * @brief 图片轮播图的点击事件
 */
- (void)PhotoBrowerCycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index{
    
    GKPhotoBrowser *browser = [GKPhotoBrowser photoBrowserWithPhotos:self.PhotoBrowser currentIndex:index];
    
    browser.showStyle = GKPhotoBrowserShowStyleNone;
    
    browser.delegate = self;
    
    [browser showFromVC:self];
}

/**
 * @brief 点击评论的图片
 */
- (void)ClickActionGoodsRateImageViewWithType:(HSQGoodsRateImageViewType)type index:(NSInteger)index RateImage:(HSQGoodsRateImageView *)rateImageView{
    
    [self.CommentBrowser removeAllObjects];
    
    MVGoodsDetailCommentListViewCell *cell = (MVGoodsDetailCommentListViewCell *)rateImageView.superview.superview;
    
    NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
    
    HSQGoodsRateListModel *FrameModel = self.evaluateGoodsVoList[indexPath.row];
    
    if (type == HSQGoodsRateImageViewTypeRate) // 评论图片
    {
        for (NSString *ImageUrl in FrameModel.image1FullList) {
            
            GKPhoto *photo = [[GKPhoto alloc] init];
            
            photo.url = [NSURL URLWithString:ImageUrl];
            
            [self.CommentBrowser addObject:photo];
        }
        
    }
    else // 追加评论的图片
    {
        for (NSString *ImageUrl in FrameModel.image2FullList) {
            
            GKPhoto *photo = [[GKPhoto alloc] init];
            
            photo.url = [NSURL URLWithString:ImageUrl];
            
            [self.CommentBrowser addObject:photo];
        }    }
    
    GKPhotoBrowser *browser = [GKPhotoBrowser photoBrowserWithPhotos:self.CommentBrowser currentIndex:index];
    
    browser.showStyle = GKPhotoBrowserShowStyleNone;
    
    browser.delegate = self;
    
    [browser showFromVC:self];
    
}


/**
 * @brief 长按事件
 */
- (void)photoBrowser:(GKPhotoBrowser *)browser longPressWithIndex:(NSInteger)index{
    
    HSQLog(@"长按手势，保存图片");
}

















@end
